package zjw;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import zjw.dao.TableMapper;

@SpringBootApplication
public class ReleaseproceApplication implements CommandLineRunner{

	@Resource
	private TableMapper tableMapper;
	public static void main(String[] args) {
		SpringApplication.run(ReleaseproceApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		String tableName=null;
		StringBuffer sb=null;
		List<String> tableList=tableMapper.gettable();
		List<String> columnList=null;
		for(int j=0;j<tableList.size();j++) {
			
			tableName=tableList.get(j);
			System.out.println(tableName);
			//System.out.println("update "+tableName+" set "+tableName+".appreleaseid=releaseid;");
			//System.out.println("INSERT INTO  "+tableName.substring(0,tableName.indexOf("_pc"))+"  SELECT * from "+tableName+" ;");
			/* sb=new StringBuffer("INSERT INTO  ");
			sb.append(tableName.substring(0,tableName.indexOf("_pc"))+" (");
			columnList=	tableMapper.getColumnName(tableName);
			for(int i=0;i<columnList.size();i++) {
				if(i<columnList.size()-1) {
					sb.append(columnList.get(i)+",");
				}else {
					sb.append(columnList.get(i)+" ) SELECT ");
				}	
			}
			for(int i=0;i<columnList.size();i++) {
				if(columnList.get(i).equals("appreleaseid")) {
					sb.append("appreleaseid");
				}else {
					sb.append(columnList.get(i));
				}
				if(i<columnList.size()-1) {
					sb.append(",");
				}else {
					sb.append(" from "+tableName+" ;");
				}	
			}*/
			//System.out.println(sb.toString());
		}
	
	}
}
